The following example demonstrates how to sort groups according to the result of a statistical function.
XAML |
Copy Code |
---|---|
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> <Grid.Resources> <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" Source="{Binding Source={x:Static Application.Current}, Path=Orders}"> <xcdg:DataGridCollectionViewSource.ItemProperties> <xcdg:DataGridItemProperty Name="Freight" GroupSortStatResultPropertyName="AVERAGE_FREIGHT"/> </xcdg:DataGridCollectionViewSource.ItemProperties> <xcdg:DataGridCollectionViewSource.StatFunctions> <xcdg:AverageFunction SourcePropertyName="Freight" ResultPropertyName="AVERAGE_FREIGHT"/> </xcdg:DataGridCollectionViewSource.StatFunctions> <xcdg:DataGridCollectionViewSource.GroupDescriptions> <xcdg:DataGridGroupDescription PropertyName="EmployeeID"/> </xcdg:DataGridCollectionViewSource.GroupDescriptions> </xcdg:DataGridCollectionViewSource> </Grid.Resources> <xcdg:DataGridControl x:Name="OrdersGrid" ItemsSource="{Binding Source={StaticResource cvs_orders}}"> <xcdg:DataGridControl.Columns> <xcdg:Column FieldName="Freight"/> </xcdg:DataGridControl.Columns> <xcdg:DataGridControl.DefaultGroupConfiguration> <xcdg:GroupConfiguration InitiallyExpanded="False"> <xcdg:GroupConfiguration.Footers> <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed="True"> <DataTemplate> <xcdg:StatRow> <xcdg:StatCell FieldName="Freight" ResultPropertyName="AVERAGE_FREIGHT" ResultConverterParameter="F2"/> </xcdg:StatRow> </DataTemplate> </xcdg:GroupHeaderFooterItemTemplate> </xcdg:GroupConfiguration.Footers> </xcdg:GroupConfiguration> </xcdg:DataGridControl.DefaultGroupConfiguration> </xcdg:DataGridControl> </Grid> |